#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Datetime: 2022/9/26 11:29
# @Author  : CHENWang
# @Site    : 
# @File    : weekly_report_data_sending.py
# @Software: PyCharm

"""
脚本说明:
"""

import os
from quant_researcher.quant.project_tool.localize import DATA_DIR
from quant_researcher.quant.project_tool.time_tool import get_today
from quant_researcher.quant.project_tool.mail_tool import monitor_param, exceptionSimpleModel
from logger import logger
import os
from task_monitor import task_to_db, check_completion_status_of_tasks


if __name__ == '__main__':
    logger.info("开始weekly_report_data_sending")
    task_to_db(os.path.basename(__file__), 'main')
    today = get_today(marker='with_n_dash')
    exceptionSimple = exceptionSimpleModel()
    emailParam = monitor_param["email"]
    emailParam["subject"] = f"周报所需数据"
    # emailParam["sender"] = {"user": 'dxsl_researcher@163.com',"password": 'JXFSRTXHMQJJDTGC',"host": 'smtp.163.com'}
    emailParam["sender"] = {"user": 'tianzhiguanlizixun@163.com', "password": 'VMUXBIXRSTMBJYDW', "host": 'smtp.163.com'}
    file_path = os.path.join(DATA_DIR, f'all_history_ohlcvm_coinmarketcap')
    file_name1 = os.path.join(file_path, f'All Coins daily Return Analysis.xlsx')
    file_name2 = os.path.join(file_path, f'All Coins weekly Return Analysis.xlsx')
    file_name3 = os.path.join(file_path, f'All Coins monthly Return Analysis.xlsx')
    file_name4 = os.path.join(file_path, f'all_drawdown_ratio.csv')

    file_path = os.path.join(DATA_DIR, f'margin_interest_rate')
    file_name5 = os.path.join(file_path, f'aave_margin_tvl_borrowed.xlsx')
    file_name6 = os.path.join(file_path, f'aave_USDC_margin_interest_rate.xlsx')
    file_name7 = os.path.join(file_path, f'binance_margin_interest_rate.xlsx')

    file_path = os.path.join(DATA_DIR, f'trading_data')
    file_name8 = os.path.join(file_path, f'DIY All Trading Amount.csv')
    file_name9 = os.path.join(file_path, f'DIY All Trading Amount - 9CEX.csv')
    file_name10 = os.path.join(file_path, f'DIY BTC Trading Amount.csv')
    file_name11 = os.path.join(file_path, f'daily_ret_characters_analysis.xlsx')

    file_path = os.path.join(DATA_DIR, f'usdt_premium')
    file_name12 = os.path.join(file_path, f'btc126_usdtcny_premium_log_prices.xlsx')
    file_name13 = os.path.join(file_path, f'okx_usdtcny_premium_ticker_log_prices.xlsx')

    file_path = os.path.join(DATA_DIR, f'onchain_data')
    file_name14 = os.path.join(file_path, f'valuation_describe_percentile_analysis_start_2017-01-01.xlsx')
    file_name15 = os.path.join(file_path, f'valuation_whole_percentile_analysis_start_2017-01-01.xlsx')
    
    file_path = os.path.join(DATA_DIR, f'borrow_interest')
    file_name16 = os.path.join(file_path,f'Binance_USDT_borrow_interest_data.xlsx')

    emailParam["file"] = [file_name1, file_name2, file_name3, file_name4, file_name5, file_name6, file_name7,
                          file_name8, file_name9, file_name10, file_name11, file_name12, file_name13,
                          file_name14, file_name15,file_name16]
    emailParam["receiver"] = ['jeffzhangzhenda@hotmail.com', '1207804643@qq.com', 'zhanghang0427@163.com']
    exceptionSimple.except_main(1, emailParam)
    task_to_db(os.path.basename(__file__), 'main', 1)
    logger.info("成功weekly_report_data_sending")
    check_completion_status_of_tasks()